package com.yanu.trace.t2s.controller;


import com.yanu.trace.t2s.entity.Emp;
import com.yanu.trace.t2s.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {

    @Autowired
    EmpService empService;
    @GetMapping("/fa")
    public List<Emp> findAll(){
        return empService.findAll();
    }


    @GetMapping("/f1/{empno}")
    public Emp fd1( @PathVariable int empno ){
        return empService.findByEmpno(empno);
    }


    @GetMapping("/add")
    public int  fd1( Emp emp   ){

        System.out.println(emp);
        return empService.addEmp(emp );
    }

    @GetMapping("/fd")
    public List<Emp>  fd2(     ){
        return  empService.findAllwithDept();
    }
    @GetMapping("/fdmo")
    public List<Emp> findAllMany2One(){
        return  empService.findAllMany2One();
}









}
